home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / share / tod / setup.exe / tod.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-16  |  2.6 KB  |  133 lines

  1. #ifndef PINEIGHT_TOD_H
  2. #define PINEIGHT_TOD_H
  3.  
  4. #include <allegro.h>
  5. #include <time.h>
  6. #include "allegdlg.h"
  7. #include "hiscore.h"
  8.  
  9. #define NUM_PIECES    10
  10. #define NUM_FLIPS      4
  11. #define NUM_BLOCKS     4
  12.  
  13. #define VIRTUAL_FPS  100
  14.  
  15. // CONSTANTS
  16. enum {
  17.   STATE_INACTIVE = 0,
  18.   STATE_GET_NEW_PIECE,
  19.   STATE_FALLING_PIECE,
  20.   STATE_CHECK4LINES,
  21.   STATE_WAIT,
  22.   STATE_FALL,
  23.   STATE_PUSHUP,
  24.   STATE_GAMEOVER,
  25.   STATE_HISCORE
  26. };
  27.  
  28. enum {
  29.   PIECE_T = 0,
  30.   PIECE_Z, PIECE_S, PIECE_J, PIECE_L, PIECE_SQUARE, PIECE_SMALL_L,
  31.   PIECE_STICK, PIECE_TINY_STICK, PIECE_SHORT_STICK,
  32.   PIECE_MAGNET,
  33.   PIECE_INVERSE
  34. };
  35.  
  36. // DATA TYPES
  37.  
  38. typedef struct TetGlobals
  39. {
  40.   BITMAP *backbits;
  41.   int endTime, doneTime;
  42.   signed char winLimit, timeLimit;
  43.   /* teflonMode: generate no stick pieces
  44.      tntMode: emulate The New Tetris for N64 */
  45.   unsigned char teflonMode, tntMode, usingJoy;
  46.   int handicap, yBase;
  47. } TetGlobals;
  48.  
  49. typedef struct Timers
  50. {
  51.   int odo, trip;
  52.   char paused;
  53. } Timers;
  54.  
  55. typedef struct Seven
  56. {
  57.   fixed leftX[768], rightX[768], leftY[768], rightY[768];
  58.   BITMAP *backBuf, *frontBuf;
  59.   int leftSide, rightSide;
  60.   int nextX;
  61. } Seven;
  62.  
  63. typedef struct Field
  64. {
  65.   unsigned char b[21][10];
  66. } Field;
  67.  
  68. typedef struct Player
  69. {
  70.   Field blockMap, auxMap;
  71.   HiGame high;
  72.   Seven *seven;
  73.  
  74.   time_t gameStarted;
  75.  
  76.   signed char  repeatTime[8];
  77.  
  78.   int curPiece[5];
  79.   int curColor[5];
  80.   int curFlip, dropMove, spinMove;
  81.   int coming, top;
  82.   int scoreFac, chainCount, vis, state;
  83.   int pieceDone, hasSwitched, inverse, handiLines;
  84.  
  85.   int x, y;
  86.   int lines, wins, hsMode;
  87.   int score, gameStart, stateTime;
  88. } Player;
  89.  
  90. typedef struct ScreenPos
  91. {
  92.   fixed a, da;
  93.   fixed b, db;
  94.   fixed c, dc;
  95.   fixed d, dd;
  96.   fixed theta, dtheta;
  97.   fixed phi, dphi;
  98.   fixed scale, dscale;
  99.   fixed amp, damp;
  100.   fixed sinusFreq, noise, heat;
  101.  
  102.   fixed xc, yc, xctarget, yctarget;
  103.   int mana; // more mana == more effects
  104.   int fps;
  105.   unsigned int fricCounter;
  106.   int coming, nEffects;
  107.   unsigned int lastBeat, midiLoop, curSong;
  108.   int fxQueue[10];
  109. } ScreenPos;
  110.  
  111. // GLOBALS
  112.  
  113. extern volatile Timers timers;
  114. extern BITMAP *tetbits;
  115. extern Player p[2];
  116. extern TetGlobals g;
  117. extern int nPlayers;
  118.  
  119. /* tetanus.c */
  120. int GameLoop(void);
  121. void *GetResource(DATAFILE *dat, const char *name);
  122. void NewGame(int pl);
  123. void DrawNext(int pl);
  124.  
  125. /* scrctl.c */
  126. unsigned int Keys2CtlWord(void);
  127. void CtlWord2Screen(ScreenPos *pos, unsigned int ctlword);
  128. void Resonance(ScreenPos *pos);
  129. unsigned int Mana2CtlWord(ScreenPos *pos, unsigned int beat);
  130. void StartSong(int songNo, DATAFILE *dat, ScreenPos *pos);
  131.  
  132. #endif
  133.